const dbUtils = require('./../utils/db-util');

const dStoreModel = {
    async getAllStoreList(){
        return await dbUtils.selectAll('dlist','*');
    },

    async getBannerList(){
        return await dbUtils.queryBySql('select * from dbanner where status = 1');
    },

    async getTodayList(){
        return await dbUtils.queryBySql('select * from today where status = 1');
    },

    async getUserByPhone(phone) {
        return await dbUtils.queryBySql(`select * from user where phone = ${phone}`);
    },

    async getUserByPhone(phone) {
        return await dbUtils.queryBySql(`select * from user where phone = ${phone}`);
    },

    async getRecentDateList() {
        return await dbUtils.queryBySql('select * from date order by date desc limit 14');
    },

    async getDateItem(date) {
        return await dbUtils.queryBySql(`select * from dlist where date = '${date}'`);
    },

    async getItemByKeyword(keyword) {
        return await dbUtils.queryBySql(`SELECT * FROM dlist WHERE CONCAT(name,key1,key2) LIKE '%${keyword}%'`);
    },

    async createUser(user) {
        return await dbUtils.insertData('user', user)
    }
};

module.exports = dStoreModel;